package com.cssy.xxkj.basic.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.byd.acegiext.domain.User;
import com.cssy.xxkj.basic.dao.BasicModeDeliveryTestDAO;
import com.cssy.xxkj.basic.entity.BasicModeDeliveryDO;
import com.cssy.xxkj.basic.service.IBasicModeDeliveryTestService;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.IDCodeTypeUtil;

@Service("basicModeDeliveryTestService")
public class BasicModeDeliveryTestServiceImpl implements IBasicModeDeliveryTestService{

	@Resource(name="basicModeDeliveryTestDAO")	
	private BasicModeDeliveryTestDAO basicModeDeliveryTestDAO;
	
	@Override
	public SearchResult findListByExample(SearchConditions scs)
			throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<BasicModeDeliveryDO>  list = basicModeDeliveryTestDAO.find(scs);
		rs.setRecordCount(basicModeDeliveryTestDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public Integer delete(String id, User user) throws SyBaseException {
		return basicModeDeliveryTestDAO.deleteBasicModeDeliveryDOByPrimaryKey(id);
	}

	@Override
	public Integer update(BasicModeDeliveryDO t, User user)
			throws SyBaseException {
		t.setBizModifyName(user.getName());
		t.setBizModifyDate(new Date());
		t.setBizVersionMark(t.getBizVersion());
		t.setBizVersion(t.getBizVersion()+1);
		return basicModeDeliveryTestDAO.updateBasicModeDeliveryDO(t);
	}

	@Override
	public BasicModeDeliveryDO save(BasicModeDeliveryDO t, User user)
			throws SyBaseException {
		String id=IDCodeTypeUtil.getId();
		t.setId(id);
		t.setBizCreatorName(user.getName());
		t.setBizCreatorDate(new Date());
		t.setBizVersion(Integer.valueOf("1"));
		basicModeDeliveryTestDAO.insertBasicModeDeliveryDO(t);
		return t;
	}

	@Override
	public BasicModeDeliveryDO findListById(String id) throws SyBaseException {
		return basicModeDeliveryTestDAO.findBasicModeDeliveryDOByPrimaryKey(id);
	}

	@Override
	public Integer deleteBizRemoved(String id) throws SyBaseException {
		return basicModeDeliveryTestDAO.deleteBizRemoved(id);
	}

}
